package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 优惠券活动控制层
 *
 * @Author wangxinyi
 * @Date 2024/12/15 17:12
 */
@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "管理端 - 优惠券相关接口")
public class ActiveController {

    @Autowired
    private IActivityService activityService;

    /**
     * 新增优惠券活动&&编辑优惠券活动
     */
    @PostMapping("/save")
    @ApiOperation("保存优惠券活动接口")
    public void saveActivity(@RequestBody ActivitySaveReqDTO dto) {
        activityService.saveActivity(dto);
    }

    /**
     * 分页查询优惠券活动接口
     */
    @GetMapping("/page")
    @ApiOperation("分页查询优惠券活动接口")
    public PageResult<ActivityInfoResDTO> activityPage(ActivityQueryForPageReqDTO dto) {
        return activityService.activityPage(dto);
    }


    /**
     * 查询优惠券活动详情接口
     */
    @GetMapping("/{id}")
    @ApiOperation("查询优惠券活动详情接口")
    public ActivityInfoResDTO selectByActivityId(@PathVariable Long id) {
        return activityService.selectByActivityId(id);
    }


    /**
     * 撤销活动
     */
    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销活动")
    public void revokeActivityById(@PathVariable Long id){
        activityService.revokeActivityById(id);
    }


}
